﻿using System;
using System.Collections.Generic;
using ExFlash.Records;

namespace ExFlash.Tags
{
    public class DefineButton2Tag : DefineButtonTag
    {
        public Boolean TrackAsMenu
        {
            get;
            protected set;
        }

        public ushort ActionOffset
        {
            get;
            protected set;
        }

        public new List<ButtonCondAction> Actions
        {
            get;
            protected set;
        }

        public DefineButton2Tag(int len,int version, int offset)
            : this(TagCodes.DefineButton2, len, version, offset)
        {
            
        }

        protected DefineButton2Tag(TagCodes code, int len, int version, int offset)
            : base(code, len, version, offset)
        {
        }

        public override void SwfDeserialize(BinaryBitReader reader)
        {
            ButtonId = reader.ReadUInt16();

            reader.SkipBits(7);
            TrackAsMenu = reader.ReadBoolean();

            reader.AlignBits();

            ActionOffset = reader.ReadUInt16();

            Characters = GetButtonRecordList(reader);

            if (ActionOffset != 0)
            {
                Actions = ButtonCondAction.GetButtonCondActionList(reader, SwfVersion);
            }
        }

        public override void SwfSerialize(byte[] arr, ref int offset)
        {
            throw new NotImplementedException();
        }
    }
}
